<template>
	<view class="">
		<view  class="notice-container">
			<view class="notice-img">
				<img src="@/static/info/gonggao.png" alt="" style="width: 100%; height: 100%;">
			</view>
			
		</view>
		<view class="notice-list" v-if="noticeList.length != 0">
			<view class="notice-content" v-for="(item,index) in noticeList" :key="index" style="display: flex;" @click="noticeDetail(item)" >
				<view class="notice-left">
					<view class="notice-title">
						{{item.title}}
					</view>
					<view class="notice-time">
						{{item.publishTime}}
					</view>
				</view>
				<view class="notice-right" v-if="item.isRead == 1"><u-icon name="arrow-right"></u-icon></view>
				<view class="nr-img" v-if="item.isRead == 0"><img src="@/static/info/weidu.png" alt="" style="width: 100%; height: 100%;"></view>
			</view>
		</view>
		<view class="no-notice" v-else>
			暂无公告!
		</view>
	</view>
	
</template>

<script>
	
	import {getNoticeList} from '@/utils/api.js'
	export default {
		data() {
			return {
				noticeList:[],
			}
		},
		onLoad(){
			this.getNoticeList()
		},
		methods: {
			noticeDetail(item){
				console.log("item.id",item);
				uni.navigateTo({
					url: '/pages/noticeIndex/noticeDetail?id=' + item.id,
					
				})
			},
			async getNoticeList(){
				uni.showLoading()
				const res = await getNoticeList()
				if(res.code == 200){
					uni.hideLoading()
				    this.noticeList = res.rows
				}
			 	
			},
		}
	}
</script>

<style>
.notice-img{
	width: 100%;
	height: 300rpx;
}
.notice-container{
	position: relative;
}
.notice-list{
	position: absolute;
	top: 180rpx;
	width: 95%;
	left: 50%;
	transform: translateX(-50%);
	
}
.notice-content{
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding:  0 20rpx;
	width: 100%;
	margin: 10rpx auto;
	background: #ffffff;
	border-radius: 16rpx;
	position: relative;
}
.notice-left{
	margin-top: 30rpx;
}
.notice-title{
	font-weight: bold;
}
.notice-time{
    margin-top: 20rpx;
		color: #cdcdcd;
		padding-bottom: 30rpx;
		font-size: 24rpx;
}
.notice-right{
	
}
.nr-img{
	width: 80rpx;
	height: 80rpx;
	position: absolute;
	top: 0;
	right: 0;
}
.no-notice{
	text-align: center;
	margin-top: 100rpx;
	color: #919090;
}
</style>
